<?php

/**
 * Subclass for performing query and update operations on the 'memberlist' table.
 *
 *
 *
 * @package lib.model
 */
class MemberlistPeer extends BaseMemberlistPeer{

    /// 基本情報のテーブル出力用 ///
    static function getListElements(){

        $c = new Criteria;
        $c->add(self::DELETE_FLG, "y", Criteria::NOT_EQUAL);

        $arr = self::doSelect($c);

        return $arr;
    }

    /// 一人分だけ返すやつ ///
    static function getPersonal($member_id){

        $c = new Criteria;
        $c->add(self::ID, $member_id);

        return self::doSelectOne($c);
    }

    /// 削除フラグが立ってる人のIDを取得 配列で返す ///
    static function getDeleteId(){

        $c = new Criteria;
        $c->add(self::DELETE_FLG, "y");

        $arr = self::doSelect($c);

        foreach($arr as $obj){
            $arr_id[] = $obj->getId();
        }
        return $arr_id;
    }

    /// ログイン関係 ///
    static function getLoginInfo($name, $passwd){

        $c = new Criteria;

        $c->add(self::NAME, $name);
        $c->add(self::PASSWORD, $passwd);

        $obj = self::doSelectOne($c);

        return $obj;
    }

    /// 渡されたmember_idの有無とかフラグとか ///
    static function checkMember($member_id){

        $c = new Criteria;

        $c->add(self::ID, $member_id);
        $c->add(self::DELETE_FLG, "n");

        $arr_member = self::doSelect($c);

        $cnt = count($arr_member);

        if($cnt === 1){
            return true;
        }
        else{
            return false;
        }
    }

}

